<?php require('common/isLogin.php');?>
<?php require('common/mysql.php');?>
<?php
// 创建Sql类的实例  
$db = new Sql();  

$sql = "SELECT * FROM account where byuser = '{$_COOKIE['user']}'";  
if($_GET['all']==1&&$_COOKIE['admin']==1){
	$sql = "SELECT * FROM account";
}
if($_GET['so']){
    $sql = "SELECT * FROM account where byuser = '{$_COOKIE['user']}' and beizhu like '%{$_GET['so']}%'";
}
$data = array_reverse($db->getAll($sql));  
$db->close();  


?>
<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<title>Hadi.账单明细</title>
		<link rel="stylesheet" href="css/style.css" />
		<link rel="stylesheet" href="css/bootstrap.min.css" />
	</head>
	<body>
		<!--头部-->
		<div class="container-fluid header">
		  <div class="row hd_title">
			  账单明细
		  </div>
		</div>
		<!--白色计算信息-->
		<!--账单明细-->
		<div class="container allzdh">
            <div class="row zdh justify-content-center">
                <form action="" method="get">
                    <div class="col">
                        <input name="so" type="text" value="" placeholder="通过备注搜索账单">
                        <input type="submit" value="搜索">
                    </div>
                </form>
            </div>
		<?php if(!$data){?>
			<div class="row zdh justify-content-center" style="color: rgb(153,153,153);padding:100px">
				没有账单 ~ 去记录一笔吧!
			</div>
		<?php }?>
			<!--这是账单行-->
			<div class="row zdh">
			<?php for($i=0;$i<count($data);$i++){ ?>
				<!--这是一条账单start-->
				<div class="row onezdh" onclick="window.location.href='account.php?id=<?php echo $data[$i]["id"];?>'">
					<div class="col-3"><img src="<?php echo $data[$i]["zcsr"] ? 'img/sr.png':'img/zc.png';?>" class="szpng"/></div>
					<div class="col">
						<div class="row catefont">
							<?php echo $data[$i]["cate"];?>
						</div>
						<div class="row mjsf">
                            <?php echo $data[$i]["date"];?>
                            账单备注：<?php echo ($data[$i]["beizhu"] ? $data[$i]["beizhu"] : '无');?>
						</div>
					</div>
					<div class="col-2">
						<div class="row justify-content-end <?php echo $data[$i]["zcsr"] ? 'redsr':'greenzc';?>">
							<?php echo $data[$i]["zcsr"] ? '+':'-';?><?php echo number_format($data[$i]["money"],2);?>
						</div>
						<div class="row justify-content-end mjsf">
							<?php echo $data[$i]["zcsr"] ? '支付宝':'微信';?>
						</div>
					</div>
				</div>
				<!--这是一条账单end-->
				<?php }?>
			</div>
			<!--这是账单行end-->
		</div>
		
		<?php if($data){?>
			<div class="container text-center" style="margin-bottom:90px;padding-top: 20px;letter-spacing: 2px;">
				<div class="row">
					<div class="col">
						<a href="" style="color: rgb(153,153,153);font-size:14px;text-decoration: none;">到底了 ~ 点击账单可编辑！</a>
					</div>
				</div>
			</div>
		<?php }?>
		
		<?php include('footer.php');?>
	</body>
</html>
